<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>实现Vue多元素过渡</title>
    <script src="vue.js"></script>
    <style>
      .fade-enter,
      .fade-leave-to {
        opacity: 0;
      }
      .fade-enter-active,
      .fade-leave-active {
        transition: opacity 0.5s;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <button @click="clear">清空</button>
      <button @click="reset">重置</button>
      <transition name="fade">
        <ul v-if="items.length > 0">
          <li v-for="item in items">{{ item }}</li>
        </ul>
        <p v-else>抱歉，没有找到您查找的内容</p>
      </transition>
    </div>
    <script>
      new Vue({
        el: "#app",
        data: {
          items: ["html", "css", "js"],
        },
        methods: {
          clear() {
            this.items.splice(0);
          },
          reset() {
            history.go();
          },
        },
      });
    </script>
  </body>
</html>
